<template>
  <div class="resMgrMain">
    <van-nav-bar title="我的素材" left-text="返回" left-arrow @click-left="$router.back()"  >
    </van-nav-bar>
    <van-tabs v-model="active">
      <van-tab :title="item.name" v-for="item in resTypes" >

        <van-row value="内容" size="large"  v-for="it in item.children"
                 class="res_row" flex>
          <van-col span="12">{{it.name}}</van-col>
          <van-col span="3"><div>{{it.resCount}}</div></van-col>
          <van-col
                  span="3"><van-icon name="cross" size="20px"
                                     @click="$router.push({path:'/resMgr/imgs/'+it.id})"/></van-col>
          <van-col
                  span="3">
            <van-uploader :after-read="onRead" multiple>
              <van-icon name="plus" size="20px"/>
            </van-uploader >
</van-col>
          <van-col
                  span="3"><van-icon name="arrow" size="20px"
                                     @click="$router.push({path:'/resMgr/imgs/'+it.id })"/></van-col>
        </van-row>

      </van-tab>
    </van-tabs>
  </div>
</template>
<script>
    // @ is an alias to /src
import ltxService from '../../services/LtxService'
    export default {
      methods:{
        onRead(file, detail)
        {
            let fileArr=[]
            if(!(file instanceof Array))
            {
              //  console.log(file)
                fileArr.push(file["file"])
            }
            else {
                for(let i=0;i<file.length;i++)fileArr.push(file[i]["file"])
            }
            //console.log(fileArr)
            ltxService.uploadRes(fileArr,"/IMAGE/NORMAL")
        }
      },
      mounted(){
        this.rootValue=document.getElementsByTagName("html")[0].style.fontSize.replace("px","");
        console.log(this.rootValue)
      },
      data(){

        return{
          rootValue:0,
          active:0,
          resTypes:[
            {name:"图片",
              children:[
                {name:"默认",id:5,resCount:0},
                {name:"随手拍",resCount:0}
              ]
            },
            {name:"视频",children:[
                {name:"默认",resCount:0},
                {name:"随手拍",resCount:0}
              ]},
            {name:"音乐",children:[
                {name:"默认",resCount:0},
                {name:"其它",resCount:0}
              ]},

          ]
        }
      },
        name: 'ResMgrMain',
        components: {
        }
    }
</script>
<style lang="scss">
  @import "../../assets/scss/base";
.resMgrMain{
  .link_cell.van-cell{
    color:$sub
  }
  .res_row{
    vertical-align: middle;

    font-size: 14px;
    align-items: center;
    text-align: center;
    padding: 10px 0;
    border-bottom: 1px solid #eee;

  }
}

</style>

